package com.gjp.securitydemo.config.auth.service.impl;

import com.gjp.securitydemo.config.auth.service.MyUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

import java.util.Collections;

@Component
public class UserDetailsServiceImpl implements MyUserDetailsService {
    @Autowired
    private PasswordEncoder passwordEncoder;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return new User(username,passwordEncoder.encode("123456"), Collections.emptyList());
    }

    @Override
    public UserDetails loadUserByMobile(String mobile) {
        return new User(mobile,passwordEncoder.encode("654321"), Collections.emptyList());
    }
}
